<!DOCTYPE html>
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">

    <!-- Bootstrap 3.3.7 -->
    <link rel="stylesheet" href="../../bootstrap/css/bootstrap.min.css">
    <link rel="stylesheet" href="../../dist/css/AdminLTE.min.css">
    <!-- AdminLTE Skins. Choose a skin from the css/skins
         folder instead of downloading all of them to reduce the load. -->
    <link rel="stylesheet" href="../../dist/css/skins/all-skins.css">
    <!--地图适配-->
    <link rel="stylesheet" href="../../dist/css/index.css">
    <title>电量温度分析</title>
    <script src="../../plugins/jQuery/jquery-2.2.3.min.js"></script>
    <!--<script src="../../plugins/jQuery/jquery-3.4.1.min.js"></script>-->

    <!--<script src="https://webapi.amap.com/maps?v=1.4.15&key=39f6a5bd38f3167dc032e09b8e6d2a12"></script>-->
    <!--<script src="https://webapi.amap.com/loca?v=1.3.0&key=39f6a5bd38f3167dc032e09b8e6d2a12"></script>-->
    <link rel="stylesheet" type="text/css" href="../../DataTables/DataTables-1.10.18/css/jquery.dataTables.min.css">
    <link rel="stylesheet" type="text/css" href="../../DataTables/Buttons-1.5.4/css/buttons.dataTables.min.css">
    <script type="text/javascript" src="../../DataTables/DataTables-1.10.18/js/jquery.dataTables.js"></script>

    <!--[if lt IE 9]>
    <script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
    <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    <![endif]-->
    <style>
        @media (max-width: 768px) {
            .cc_from_item{
                width:100% !important;
            }

        }
        body,html,#container{
            height: 100%;
            margin: 0px;
            font:12px Arial;
        }
        .taiwan{
            border: solid 1px red;
            color: red;
            float: left;
            width: 50px;
            background-color: rgba(255,0,0,0.1)
        }

        .flex-container {
            display: flex;
        }
        /*.flex-container.first {*/
        /*flex-flow: row;*/
        /*}*/
        /* Initial value. Main-axis is
           inline, no wrap. */

        .flex-container.second {
            flex-flow: column wrap;
            -webkit-flex-flow: column wrap;
        }
        /* Main-axis is block-direction (top to bottom)
           and lines wrap in the inline direction (rightwards). */

        /*.flex-container.third {*/
        /*flex-flow: row-reverse wrap-reverse;*/
        /*}*/
        /* Main-axis is the opposite of inline direction
           (right to left). New lines wrap upwards. */
        /* other styles just for format */

        ul {
            padding: 0;
        }
        li {
            list-style: none;
        }
        .flex-container {
            background: deepskyblue;
            width: 1080px;
            height: 570px;
            margin: 5px auto;
        }
        /*.flex-container.first {*/
        /*height: 100px;*/
        /*}*/
        .flex-item {
            /*background: tomato; #1a7bb9;*/
            background: #FAF0E6;
            padding: 5px;
            width: 1060px;
            height: 275px;
            margin: 5px;
            line-height: 80px;
            color: white;
            font-weight: bold;
            font-size: 2em;
            text-align: center;
            border: 1px;
        }
        h1 {
            font-size: 22px;
            text-align: center;
        }
        .flex-demo {
            display: flex;
        }
    </style>
    <script src="../../bootstrap/js/bootstrap.js"></script>
    <script src="../../bootstrap/js/echarts-all-3.js"></script>
</head>
<body>
    <div class="row" style="padding-top: 20px;margin-top: 20px">
        <div class="col-md-12">
            <div class="box-body">
                <form role="form">
                    <!-- text input -->
                    <div class="form-group  has-success select-5">
                        <style>
                            @media (min-width: 992px){
                                .select-5 .form-control{
                                    width:18%;
                                    margin-left:15px;
                                }
                            }

                        </style>
                        <label style="padding-bottom: 5px">所属区域(*)</label>
                        <div class="row">
                            <select id="select_province" class="form-control col-md-2" style="margin-bottom: 5px">
                                <!--<option value="-1">请选择</option>-->
                                <option value="0" style="color: #00a65a">全国</option>
                                <option value="150000000000">内蒙古自治区</option>
                                <option value="510000000000">四川省</option>
                                <option value="530000000000">云南省</option>
                                <option value="540000000000">西藏自治区</option>
                                <option value="610000000000">陕西省</option>
                                <option value="620000000000">甘肃省</option>
                                <option value="630000000000">青海省</option>
                                <option value="640000000000">宁夏回族自治区</option>
                                <option value="650000000000">新疆维吾尔族自治区</option>
                                <option value="660000000">建设兵团</option>
                            </select>
                            <select id="select_city" class="form-control col-md-2" style="margin-bottom: 5px">
                                <option value="-1">请选择</option>
                            </select>
                            <select id="select_county" class="form-control col-md-2" style="margin-bottom: 5px"><option value="-1">请选择</option></select>
                            <select id="select_village" class="form-control col-md-2" style="margin-bottom: 5px"><option value="-1">请选择</option></select>
                            <select id="select_hamlet" class="form-control col-md-2" style="margin-bottom: 5px"><option value="-1">请选择</option></select>
                        </div>
                    </div>
                </form>
            </div>
        </div>
        <div class="box-body">
            <div class="col-md-12">
                <div class="row">
                    <div class="col-md-8" style="margin-bottom:5px;margin-left: 3px">
                        <span class="col-md-8" style="padding-left: 5px;padding-right: 0;">
                            <input type="text" class="form-control" placeholder="请选择项圈"  id="input_neckletid" disabled/>
                        </span>
                        <span class="col-md-3">
                            <button type="button" id="btn_neckletlist" class="btn btn-info btn-flat">批量选择项圈</button>
                        </span>
                    </div>
                </div>
            </div>
        </div>
        <div class="box-body">
            <div class="col-md-12">
                <div class="row">
                    <div class="col-md-6 cc_from_item" style="margin-left:5px;margin-bottom:5px;width:500px;">
                        起止时间:
                        <input id="input_begintime" class="form-control cc_from_item" style="display:inline-block;width: 200px;" type="datetime-local" value="2019-06-23T00:00"/>
                        <span style="display:inline-block;">-</span>
                        <input id="input_endtime" class="form-control cc_from_item" style="display:inline-block;width:200px;" type="datetime-local" value="2019-06-24T10:00"/>
                    </div>
                    <div class="col-md-2" style="padding-right: 0;">
                        <span class="col-md-8" style="padding-left: 0;">
                            <button type="button" id="btn_drawvol" class="btn btn-info btn-flat">绘制电压温度图表</button>
                        </span>
                        <!--<span class="col-md-3">-->
                        <!--<button type="button" id="btn_drawtemp" class="btn btn-info btn-flat">绘制温度图表</button>-->
                        <!--</span>-->
                    </div>
                    <div class="col-md-4" style="margin-bottom:5px;padding-left: 0px">
                        <span class="col-md-3">
                            <button type="button" id="btn_exportExcel" class="btn btn-info btn-flat">导出Excel表</button>
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <div class="content">
        <div id="pad-wrapper" class="users-list">
            <div class="row chart">
                <div class="col-md-12">
                    <div style="text-align: center;">
                        <h4 id="h3_logtitle"></h4>
                    </div>
                    <div class="flex-demo">
                        <ul class="flex-container second">
                            <li class="flex-item">
                                <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
                                <div id="main" style="width: 100%;height:100%;"></div>
                            </li>
                            <li class="flex-item">
                                <!-- 为ECharts准备一个具备大小（宽高）的Dom -->
                                <div id="main2" style="width: 100%;height:100%;"></div>
                            </li>
                        </ul>
                    </div>
                </div>
            </div>
        </div>
        <div id = "export_form" style="display:none"></div>
        <div id="dogid" style="display: none">0</div>

        <div class="modal fade" id="dogInfoDiv" tabindex="-1" role="dialog">
            <div class="modal-dialog model80" >

                <div class="modal-content">
                    <div class="modal-body">
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->

        <div class="modal fade" id="doglist" tabindex="-1" role="dialog">
            <div class="modal-dialog model80" >

                <div class="modal-content">
                    <div class="modal-header">
                        <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                        <h4 class="modal-title">信息详情</h4>
                    </div>
                    <div class="modal-body">
                        <form role="form">
                            <table data-toggle="table" class="table  table-bordered" id="datatable" style="table-layout:fixed;">
                                <thead>
                                <tr>
                                    <th><input type="checkbox" name="select_all" id="select-all" class="select-all"></th>
                                    <th>犬主姓名</th>
                                    <th>犬名</th>
                                    <th>犬只政府编码</th>
                                    <th>项圈编号</th>
                                </tr>
                                </thead>
                                <tbody id="tbody">

                                </tbody>
                            </table>
                        </form>
                    </div>
                    <div class="modal-footer">
                        <button class="btn btn-primary" onclick="choosedog()" type="button">
                            选择
                        </button>
                    </div>
                </div><!-- /.modal-content -->
            </div><!-- /.modal-dialog -->
        </div><!-- /.modal -->

    </div>
    <script type="text/javascript">
        var viewdata;
        var necnum = 0;
        var posnum = 0;
        $(function () {
            var datares = {};
            // $.ajax({
            //     url: "/aidog/api/register/4",
            //     async:false,
            //     type: "GET",
            //     success: function (data) {
            //         datares = eval("(" + data + ")");
            //     }
            // });
            $.getJSON ("/aidog/adminlte/pages/ui_js/district.json", function (data)
            {
                datares = data;
            });

            //日历控件
            var date2 = new Date();
            date2.setDate(new Date().getDate() - 30);
            $("#input_endtime").val(timeinput((new Date()).valueOf()));
            $("#input_begintime").val(timeinput(date2));


            var districtcode = "";
            var level = "";
            var excelnecid = "";
            var excelbegintime = "";
            var excelendtime = "";
            $("#select_province").on('change', function () {
                districtcode = $(this).find('option:selected').val();
                // if(districtcode == "0"){
                //     $("#select_city").attr("disabled","disabled");
                //     $("#select_county").attr("disabled","disabled");
                //     $("#select_village").attr("disabled","disabled");
                //     $("#select_hamlet").attr("disabled","disabled");
                // }else{
                //
                // }
                level = "province";
                var selectvalue = $(this).find('option:selected').val();
                selectvalue = selectvalue.substring(0,2);
                $("#select_city").find("option").remove();
                var select_city = document.getElementById("select_city");
                select_city.options.add(new Option("请选择", "-1"));
                if ($('#modalselect_adminlevel').find('option:selected').text()!="省级") {
                    for (var i = 0; i < datares.data1.length; i++) {
                        if (datares.data1[i].districtcode.toString().substring(0, 2) == selectvalue) {
                            //遍历后台传回的结果，一项项往select中添加option
                            select_city.options.add(new Option(datares.data1[i].districtname, datares.data1[i].districtcode));
                        }
                    }
                }
                $("#select_county").find("option").remove();
                var select_county = document.getElementById("select_county");
                select_county.options.add(new Option("请选择", "-1"));

                $("#select_village").find("option").remove();
                var select_village = document.getElementById("select_village");
                select_village.options.add(new Option("请选择", "-1"));

                $("#select_hamlet").find("option").remove();
                var select_hamlet = document.getElementById("select_hamlet");
                select_hamlet.options.add(new Option("请选择", "-1"));
            });
            $("#select_city").on('change', function () {
                districtcode = $(this).find('option:selected').val();
                level = "city";
                var selectvalue = $(this).find('option:selected').val();
                $("#select_county").find("option").remove();
                selectvalue = selectvalue.substring(0, 4);
                var select_county = document.getElementById("select_county");
                select_county.options.add(new Option("请选择", "-1"));
                if ($('#modalselect_adminlevel').find('option:selected').text() != "市级") {
                    for (var i = 0; i < datares.data2.length; i++) {
                        if (datares.data2[i].districtcode.toString().substring(0, 4) == selectvalue) {
                            //遍历后台传回的结果，一项项往select中添加option
                            select_county.options.add(new Option(datares.data2[i].districtname, datares.data2[i].districtcode));
                        }
                    }
                }
                $("#select_village").find("option").remove();
                var select_village = document.getElementById("select_village");
                select_village.options.add(new Option("请选择", "-1"));

                $("#select_hamlet").find("option").remove();
                var select_hamlet = document.getElementById("select_hamlet");
                select_hamlet.options.add(new Option("请选择", "-1"));
            });
            $("#select_county").on('change', function () {
                districtcode = $(this).find('option:selected').val();
                level = "county";
                var selectvalue = $(this).find('option:selected').val();
                $("#select_village").find("option").remove();
                selectvalue = selectvalue.substring(0, 6);
                var select_village = document.getElementById("select_village");
                select_village.options.add(new Option("请选择", "-1"));
                if ($('#modalselect_adminlevel').find('option:selected').text() != "县级") {
                    for (var i = 0; i < datares.data3.length; i++) {
                        if (datares.data3[i].districtcode.toString().substring(0, 6) == selectvalue) {
                            //遍历后台传回的结果，一项项往select中添加option
                            select_village.options.add(new Option(datares.data3[i].districtname, datares.data3[i].districtcode));
                        }
                    }
                }
                $("#select_hamlet").find("option").remove();
                var select_hamlet = document.getElementById("select_hamlet");
                select_hamlet.options.add(new Option("请选择", "-1"));
            });
            $("#select_village").on('change', function () {
                districtcode = $(this).find('option:selected').val();
                level = "village";
                var selectvalue = $(this).find('option:selected').val();
                $("#select_hamlet").find("option").remove();
                selectvalue = selectvalue.substring(0, 9);
                var select_hamlet = document.getElementById("select_hamlet");
                select_hamlet.options.add(new Option("请选择", "-1"));
                if ($('#modalselect_adminlevel').find('option:selected').text() != "乡级") {
                    for (var i = 0; i < datares.data4.length; i++) {
                        if (datares.data4[i].districtcode.toString().substring(0, 9) == selectvalue) {
                            //遍历后台传回的结果，一项项往select中添加option
                            select_hamlet.options.add(new Option(datares.data4[i].districtname, datares.data4[i].districtcode));
                        }
                    }
                }
            });

            $("#select_hamlet").on('change', function () {
                districtcode = $(this).find('option:selected').val();
                level = "hamlet";
            });


            $("#btn_drawvol").click(function () {
                var senddata = {};
                var necid = null;
                if($("#input_neckletid").val()!=null && $("#input_neckletid").val()!="" && $("#input_neckletid").val()!="输入项圈编号"){
                    necid = $("#input_neckletid").val();
                    necnum = necid.split("|").length == 1?1:necid.split("|").length-1;
                }else{
                    alert("未选择项圈！");
                    necnum = 0;
                    posnum = 0;
                    return;
                }
                var begintime = $("#input_begintime").val()+":00";
                var endtime = $("#input_endtime").val()+":00";
                senddata.districtcode = districtcode;
                senddata.level = level;
                senddata.begintime = begintime;
                senddata.endtime = endtime;
                senddata.necid = necid;

                excelnecid = necid;
                excelbegintime = begintime;
                excelendtime = endtime;
                $.ajax({
                    url: "/aidog/api/getnecvoltemplist",
                    type: "POST",
                    data: senddata,
                    beforeSend: function (request) {
                        request.setRequestHeader("token", window.localStorage.getItem("aidog_token"));
                    },
                    success: function (data) {
                        if (data.success) {
                            drawMap(data.data.voltemplist);
                            posnum = data.data.voltemplist.length;
                        }
                        else {
                            return;
                        }
                    }
                })
            });

            $("#btn_neckletlist").click(function () {
                var senddata = {};
                senddata.startitem = 1;
                senddata.pagesize = 100000;
                senddata.districtcode = districtcode;
                senddata.level = level;
                $.ajax({
                    url: "/aidog/api/getdoglist",
                    type: "POST",
                    data: senddata,
                    beforeSend: function (request) {
                        request.setRequestHeader("token", window.localStorage.getItem("aidog_token"));
                    },
                    success: function (data) {
                        if (data.data.data == null) {
                            alert(data.data.msg);
                            return;
                        }
                        else {
//                            var select_necklet = document.getElementById("select_necklet");
                            viewdata = $.extend(true,[],data.data.data);
                            for(var i = viewdata.length-1;i>=0;i--){
//                                if(data.data.data[i].necId!="-1"){
//                                    //遍历后台传回的结果，一项项往select中添加option
//                                    select_necklet.options.add(new Option(data.data.data[i].necId, data.data.data[i].dogId));

//                                }
                                viewdata[i].check = "<input name='check' id='\""+viewdata[i].necId+"\"' class=\"checkbox neccheck\" type=\"checkbox\" />";
                                if(viewdata[i].necId == "-1"){
                                    viewdata.splice(i,1);
                                }
                            }

                            $("#doglist").modal('show');
                            $("#doglist").on("shown.bs.modal",function(){
                                var dt = $('#datatable').DataTable({
                                    data: viewdata,
                                    "jQueryUI": true,
                                    'paging'      : true,
                                    lengthMenu: [　//显示几条数据设置
                                        [10, 20,30, 50,-1],
                                        ['10 条', '20 条','30条', '50 条','全部']
                                    ],
                                    'searching'   : true,
                                    'ordering'    : true,
                                    "pageLength": 10, //每行显示记录数
                                    'info'        : true,
                                    'bAutoWidth'  : false,
                                    "responsive": false,
                                    //允许重建
                                    "destroy": true,
                                    "scrollX":true,
                                    "oLanguage": {
                                        buttons: {
                                            pageLength: {
                                                _: "每页%d条记录",
                                                '-1': "显示所有记录"
                                            }
                                        },
                                        "sLengthMenu": "每页显示 _MENU_ 条记录",
                                        "sZeroRecords": "暂无数据",
                                        "sInfo": "当前显示 _START_ 到 _END_ 条，共 _TOTAL_ 条记录",
                                        "sInfoEmtpy": "暂无数据",
                                        "sInfoFiltered": "数据表中共为 _MAX_ 条记录)",
                                        "sProcessing": "正在加载中",
                                        "sSearch": "搜索",
                                        "sUrl": "",
                                        "oPaginate": {
                                            "sFirst": "第一页",
                                            "sPrevious": " 上一页 ",
                                            "sNext": " 下一页 ",
                                            "sLast": " 最后一页 "
                                        }
                                    },
                                    "scrollY": "200px",
                                    "dom": 'Bfrtip',
                                    "processing": true,
                                    "columns": [
                                        {
                                            "class":          "details-control",
                                            "orderable":      false,
                                            "data":           "check",
                                            "defaultContent": "",
                                            "width": "1px"
                                        },
                                        { "data": "ownerName","width":"60px" },
                                        { "data": "dogName","width":"60px"  },
                                        { "data": "dogGovcode","width":"70px"  },
                                        { "data": "necId","width":"70px"}
                                    ]
                                });
                            });

                        }
                    }
                })
            });

            //页面上点击此属性，将当前页的列表数据全部选中
            $('.select-all').on('click', function () {
                if (this.checked) {
                    $('.checkbox.neccheck').each(function () {
                        this.checked = true;
                    });
                } else {
                    $('.checkbox.neccheck').each(function () {
                        this.checked = false;
                    });
                }
            });

            $("#btn_stanum").click(function () {
                alert("项圈数量： "+ necnum + "\r" + "位置总数： "+ posnum);
            });

            $("#btn_exportExcel").click(function () {
                if($("#input_neckletid").val()!=null && $("#input_neckletid").val()!="" && $("#input_neckletid").val()!="输入项圈编号"){
                    necid = $("#input_neckletid").val();
                    necnum = necid.split("|").length == 1?1:necid.split("|").length-1;
                }else{
                    alert("未选择项圈！");
                    necnum = 0;
                    posnum = 0;
                    return;
                }
                $("#export_form").html(
                    "<form action='/aidog/api/exportExcel' method='post' id='btn_export' style='display:none'>"+
                    "<input type=hidden name='token' value='"+window.localStorage.getItem("aidog_token")+"' />"+
                    "<input type=hidden name='level' value='"+level+"' />"+
                    "<input type=hidden name='necid' value='"+excelnecid+"' />"+
                    "<input type=hidden name='begintime' value='"+excelbegintime+"' />"+
                    "<input type=hidden name='endtime' value='"+excelendtime+"' />"+
                    "<input type=hidden name='districtcode' value='"+districtcode+"' />"+
                    "</form>"
                );
                $("#btn_export").submit(); //提交
                $("#export_form").html(""); //清空div
            });

        });

        function dealWithData(data){
            let c = [];
            let d = {};
            data.forEach(element => {
                if(!d[element.deviceId]){
                    c.push({
                        deviceId: element.deviceId,
                        allData: [element]
                    });
                    d[element.deviceId] = element;
                }else{
                    c.forEach(ele => {
                        if(ele.deviceId == element.deviceId){
                            ele.allData.push(element);
                        }
                    });
                }
            });
            return c;
        }

        function drawMap(datares) {

            var ceshi = dealWithData(datares);

            var vols = [];
            var temps = [];
////            var times = [];
////            var vs = [];
////            var ts = [];
//            for (var i = 0; i < datares.length; i++) {
//                var voltemp = [];
////                voltemp.push(datares[i].lng + "," + datares[i].lat);
//                voltemp.push(datares[i].realtime);
//                voltemp.push(datares[i].vol);
//                vols.push(voltemp);
//                var temp = [];
//                temp.push(datares[i].realtime);
//                temp.push(datares[i].temp);
//                temps.push(temp);
//
////                times.push(datares[i].realtime);
////                vs.push(datares[i].vol);
////                ts.push(datares[i].temp);
//            }
            var myChart = echarts.init(document.getElementById('main'));
            myChart.clear();
            var myChart2 = echarts.init(document.getElementById('main2'));
            myChart2.clear();


            var series =  [];
            var seriestemp = [];
            for (var m = 0; m < ceshi.length; m++) {
                var vols_ = [];
                var temps_ = [];
                for(var n = 0; n < ceshi[m].allData.length; n++){
                    var voltemp = [];
                    voltemp.push(ceshi[m].allData[n].realtime);
                    voltemp.push(ceshi[m].allData[n].vol);
                    vols_.push(voltemp);

                    var tempt = [];
                    tempt.push(ceshi[m].allData[n].realtime);
                    tempt.push(ceshi[m].allData[n].temp);
                    temps_.push(tempt);

                }
                var series_piece = {};
                series_piece.name = ceshi[m].deviceId;
                series_piece.type = 'line';
                series_piece.data = vols_;


                var markPoint = {};
                var markPointdata = [];
                var type1 = {type : 'max', name: '最大值'};
                var type2 = {type : 'min', name: '最小值'};
                markPointdata.push(type1);
                markPointdata.push(type2);
                markPoint.data = markPointdata;


                var markLine = {};
                var markLinedata = [];
                var type3 = {type : 'average', name: '平均值'};
                markLinedata.push(type3);
                markLine.data = markLinedata;

                series_piece.markPoint = markPoint;
                series_piece.markLine = markLine;
                series[m] = series_piece;

                var tempseries_piece = {};
                tempseries_piece.name = ceshi[m].deviceId;
                tempseries_piece.type = 'line';
                tempseries_piece.data = temps_;
                tempseries_piece.markPoint = markPoint;
                tempseries_piece.markLine = markLine;
                seriestemp[m] = tempseries_piece;
            }

            option = {
                title : {
                    text: '项圈电压趋势',
                },
                tooltip : {
                    trigger: 'axis',
                    showDelay : 0,
                    formatter : function (params) {
                        if (params[0].value.length > 1) {
                            return params[0].seriesName + ' :<br/>'
                                + timetrans(params[0].value[0]) + ' '
                                + params[0].value[1] + 'V ';
                        }
                        else {
                            return params.seriesName + ' :<br/>'
                                + timetrans(params.name) + '  '
                                + params.value + 'V ';
                        }
                    },
                    axisPointer:{
                        show: true,
                        type : 'cross',
                        lineStyle: {
                            type : 'dashed',
                            width : 1
                        }
                    }
                },
                calculable : true,
                xAxis : [
                    {
                        type : 'value',
                        scale:true,
                        axisLabel : {
                            formatter:  function (params) {
                                return timetrans(params)
                            }

                        }
                    }
                ],
                yAxis : [
                    {
                        type : 'value',
                        axisLabel : {
//                            formatter: '{value} .00V'
                            formatter:  function (params) {
                                if(params==0){
                                    return params;
                                }else{
                                    return params+'.00 V';
                                }
                            }
                        }
                    }
                ],
                series : series
            };
            myChart.setOption(option);

            option2 = {
                title : {
                    text: '项圈温度趋势',
                },
                tooltip : {
                    trigger: 'axis',
                    showDelay: 0,
                    formatter: function (params) {
                        if (params[0].value.length > 1) {
                            return params[0].seriesName + ' :<br/>'
                                + timetrans(params[0].value[0]) + ' '
                                + params[0].value[1] + '℃';
                        }
                        else {
                            return params.seriesName + ' :<br/>'
                                + timetrans(params.name) + '  '
                                + params.value + '℃ ';
                        }
                    },
                    axisPointer:{
                        show: true,
                        type : 'cross',
                        lineStyle: {
                            type : 'dashed',
                            width : 1
                        }
                    }
                },
                calculable : true,
                xAxis : [
                    {
                        type : 'value',
                        scale:true,
                        axisLabel : {
                            formatter:  function (params) {
                                return timetrans(params)
                            }

                        }
                    }
                ],
                yAxis : [
                    {
                        type : 'value',
                        axisLabel : {
                            formatter: '{value}  ℃'
                        }
                    }
                ],
                series : seriestemp
            };
            myChart2.setOption(option2);
        }

        function timetrans(date){
//    var date = new Date(date*1000);//如果date为13位不需要乘1000
            var date = new Date(date);
            var Y = date.getFullYear() + '-';
            var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
            var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + ' ';
            var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
            var m = (date.getMinutes() <10 ? '0' + date.getMinutes() : date.getMinutes()) + ':';
            var s = (date.getSeconds() <10 ? '0' + date.getSeconds() : date.getSeconds());
            return Y+M+D+h+m+s;
        }

        function timeinput(date){
            var date = new Date(date);
            var Y = date.getFullYear() + '-';
            var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
            var D = (date.getDate() < 10 ? '0' + (date.getDate()) : date.getDate()) + 'T';
            var h = (date.getHours() < 10 ? '0' + date.getHours() : date.getHours()) + ':';
            var m = (date.getMinutes() <10 ? '0' + date.getMinutes() : date.getMinutes());
            return Y+M+D+h+m;
        }

        function choosedog() {
            var neccheck = $('.neccheck');
            var arr = []
            var spanarr = "";
            neccheck.map(function(item){
                if(neccheck[item].checked){
                    arr.push(neccheck[item].id);
                    spanarr += neccheck[item].id +"|";
                }
            })
            spanarr = spanarr.replace(/\"/g, "");
            $("#input_neckletid").val(spanarr);
            $("#doglist").modal('hide');
        }
    </script>
    <script type="text/javascript" src="https://webapi.amap.com/demos/js/liteToolbar.js"></script>
</body>
</html>